<?php 
include './functions.php';
session_start();

$data = file_get_contents('./Db/db.json');
$data = json_decode($data,true);
// $data = array_reverse($data,true);
krsort($data);
$row=5;//每页显示的行数
$pages=ceil(count($data)/$row);
$page=isset($_GET['page'])?$_GET['page']:1;
if (isset($_GET['myMsg'])){
	$pages=ceil(deep_array_count_values($_SESSION['username'],$data)/$row);
	$page=isset($_GET['page'])?$_GET['page']:1;
}

$data=array_slice($data,($page-1)*$row,$row,true);

if (isset($_GET['myMsg'])) {
    include './Tpl/myMsg.html';
}else{
    if(isset($_SESSION['username'])){
    	include './Tpl/indexLoginSuccess.html';
    }else{
    	include './Tpl/index.html';
    }
}
// include './Tpl/index.html';
?>
